package cn.niit.smbms.service.impl;

import cn.niit.smbms.dao.SysUserReceiveAddresMapper;
import cn.niit.smbms.entity.SysUserReceiveAddres;
import cn.niit.smbms.service.SysUserReceiveAddresService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class SysUserReceiveAddresServiceImpl implements SysUserReceiveAddresService {

    @Autowired
    private SysUserReceiveAddresMapper addresMapper;

    /**
     * 查询收货地址列表
     * @param addres
     * @return
     */
    @Override
    public List<SysUserReceiveAddres> selectByCondition(SysUserReceiveAddres addres) {
        return addresMapper.selectByCondition(addres);
    }

    /**
     * 更新收货地址
     * @param addres
     * @return
     */
    @Override
    public int update(SysUserReceiveAddres addres) {
        return addresMapper.update(addres);
    }

    /**
     * 添加收货地址
     * @param addres
     * @return
     */
    @Override
    public int add(SysUserReceiveAddres addres) {
        addres.setGmtCreate(new Date());
        return addresMapper.insert(addres);
    }

    /**
     * 查询收货地址列表
     * @param receiveId
     * @return
     */
    @Override
    public SysUserReceiveAddres selectByreceiveId(Long receiveId) {
        return addresMapper.selectByreceiveId(receiveId);
    }
}
